package com.sky.mapper;

import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ShoppingCartMapper {

    //查询购物车信息
    List<ShoppingCart> select(ShoppingCart shoppingCart);

    //根据id修改数量
    @Update("update shopping_cart set number=#{number} where id=#{id}")
    void updataNumber(ShoppingCart shoppingCart1);

    //插入新购物车一体信息
    @Insert("insert into shopping_cart( name, image, user_id, dish_id, setmeal_id, dish_flavor, number, amount, create_time) " +
            "VALUES (#{name},#{image},#{userId},#{dishId},#{setmealId},#{dishFlavor},#{number},#{amount},#{createTime})")
    void insert(ShoppingCart shoppingCart);

    //删除该用户的所有的购物车信息
    @Delete("delete from shopping_cart where user_id=#{userId}")
    void deleteAll(ShoppingCart shoppingCart);

    //直接删除一条信息
    void delete(ShoppingCart shoppingCart);
}
